import React, { Component } from 'react';
import { get } from 'utils/http'
import { NavWrap } from './styledIndex'

class Nav extends Component {
    state = {
        list: []
    }

    async componentDidMount() {
        let result = await get({
            url: '/api/home/index/getClassifyHome?city_id=0&abbreviation=&version=6.0.9&referer=2'
        })

        this.setState({
            list: result.data.classify_list
        })
    }


    render() {
        return (
            <NavWrap>
               {
                   this.state.list.length && (
                       this.state.list.map((value) => (
                           <figure key={value.id}>
                               <img src={value.pic} alt={value.name}/>
                               <figcaption>
                                    <h4>{value.name}</h4>
                               </figcaption>
                           </figure>
                       ))
                   )
               }
            </NavWrap>
        );
    }
}

export default Nav;